package cn.topcodes.tcsf.admin.mapper;

import cn.topcodes.tcsf.admin.domain.entity.SysMenu;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SysMenuMapper extends Mapper<SysMenu> {

    @Select("select distinct m.id as id,m.name as name,m.url as url,m.sort as sort,m.i18n as i18n,m.icon_cls as iconCls,m.parent_id as parentId " +
            "from t_sys_menu m " +
            "left join t_sys_menu_permission_rela mpr on m.id=mpr.menu_id " +
            "left join t_sys_permission p on mpr.perm_id=p.id " +
            "left join t_sys_role_permission_rela rpr on rpr.perm_id=p.id " +
            "left join t_sys_role r on rpr.role_id=r.id " +
            "left join t_sys_user_role_rela urr on urr.role_id=r.id " +
            "where urr.user_id=#{userId} and m.data_state='Enable'")
    List<SysMenu> findPermedMenu(Long userId);
}